//==============================================================================
//
//               Copyright (C) 2002  Dick van Oudheusden
//  
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================
// 
//  $Date: 2003-10-31 08:12:34 $ $Revision: 1.1 $
//
//==============================================================================

#include <stdlib.h>

#include "ofc/config.h"

#include "ofc/DFile.h"
#include "ofc/DImageHeader.h"

#include "DInc.h"
#include "DTest.h"

//-Misc------------------------------------------------------------------------

void DImageHeader_test()
{
  DFile        *file = [DFile        alloc];
  DImageHeader *img  = [DImageHeader alloc];

  STARTTEST();

  [file init :"note.tif" :"r"];
  
  [img init :file];
  TEST([img type] == DIM_TIFF);
  TEST(strcmp([img extension], "tiff") == 0);
  TEST(strcmp([img mime_type], "image/tiff") == 0);

  [file free];

  file = [DFile alloc];
  [file init :"note.gif" :"r"];
  TEST([file isOpen]);
  TEST([img inspect :file]);
  TEST([img type] == DIM_GIF);
  [file free];

  file = [DFile alloc];
  [file init :"note.png" :"r"];
  TEST([file isOpen]);
  TEST([img inspect :file]);
  TEST([img type] == DIM_PNG);
  [file free];

  file = [DFile alloc];
  [file init :"tennis.jpg" :"r"];
  TEST([file isOpen]);
  TEST([img inspect :file]);
  TEST([img type] == DIM_JPEG);
  [file free];
  
  [img  free];

  STOPTEST();
}

